# encoding: utf-8
module ItemsHelper

  def show_start(item)
    (item.global_rating.to_f/2).to_s.sub(/\./, '')
  end

  #分类链接
  def l_c(item)
    a = []
    a << [link_to(item.cat1_name,"/categories/#{item.cat1_id}")]  unless item.cat1_id.blank?
    a << ["/"] if item.cat1_id and item.cat2_id
    a << [link_to(item.cat1_name,"/categories/#{item.cat2_id}")]  unless item.cat2_id.blank?
    a
  end

  #评分的格式化处理
  def format_num(num=nil)
    r = (num.to_f / 10).ceil * 5
    format("%02i",r)
  end

  def l_u(item)
    user = item.first_review_user unless item.blank? #第一点评用户
    unless user.blank?
      [[link_to(user.nick_name, user_path(user))],["第一评"]]
    else
      ""
    end
  end

end
